package com.crm.Servlet;

import com.crm.Service.CustomerService;
import com.crm.ServiceImpl.CustomerServiceImpl;
import com.crm.pojo.Customer;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.ForkJoinPool;

/**
 * @version : 1.0
 * @auther : hjx
 * @Date : 2021/7/1
 * @Description : 实训
 */
public class queryCustomByName extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        resp.setContentType("text/html; charset=UTF-8");
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");

        String name = req.getParameter("custName");
        CustomerService customerService = new CustomerServiceImpl();
        List<Customer> customers = customerService.queryCustomByName(name);
        req.setAttribute("customers",customers);
        req.getRequestDispatcher("list.jsp").forward(req,resp);
    }


}

